<template>
    <div class="register">
        <div class="header">
            <div class="header-left">
                <div class="imgBox">
                </div>
                <div class="tit">
                    微志益
                </div>
                <div class="ms">
                    致力于公益的绿色平台
                </div>
            </div>
            <router-link :to="'./Index'" tag="div" class="toIndex"> 首页-></router-link>
        </div>

        <div class="content">
            <div class="center">
                <div class="hellow">
                    欢迎注册微志益账户
                </div>
                <div class="username inputBox">
                    <input type="text" placeholder="用户名（2~8个汉字，字母，数字，下划线）" v-model="username" @input="unameCheck">
                    <span :class="this.namespan=='√'?'ture':'false'">{{namespan}}</span>
                </div>
                <div class="password inputBox">
                    <input type="password" placeholder="密码（6-16位字母、数字）" v-model="password" @input="passwordCheck">
                    <span :class="this.passwordspan=='√'?'ture':'false'">{{passwordspan}}</span>
                </div>
                <div class="phone inputBox">
                    <input type="text" placeholder="手机号码" v-model="phone" @input="phoneCheck">
                    <span :class="this.phonespan=='√'?'ture':'false'">{{phonespan}}</span>
                </div>
                <div class="check inputBox">
                    <input type="checkbox" v-model="ischeck">
                    <label for="">
                        同意
                        <a href="">《服务条款》</a>
                        及
                        <a href="">《隐私政策》</a>
                    </label>
                </div>
            </div>
            <button class="registBtn" @click="register">立即注册</button>
            <p class="toLogin">已有账号，去 <span @click="toLogin">登录</span></p>
        </div>
    </div>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions} from 'vuex'
import {unameCheck,passwordCheck,phoneCheck,register} from '@/utils/valid'
export default {
    data() {
        return {
            userData:{
                uname:"",
                password:"",
                phone:"",
            },
            username:"",
            namespan:"",
            isname:false,
            password:"",
            passwordspan:"",
            ispass:false,
            phone:"",
            phonespan:"",
            isphone:false,
            ischeck:"",
        }
    },
    methods:{
        toLogin(){
            this.$router.push("./login")
        },
        unameCheck,
        passwordCheck,
        phoneCheck,
        register,
    },
    mounted(){
    },
    computed: {
        a(){
            return this.$store.state.users;
        }
    }
}
</script>

<style lang="scss" scoped>
    .register{
        width: 100%;
        position: fixed;
        top: 0;
        bottom: 0;
        background: #eff8ff;
        .header{
            width: 100%;
            display: flex;
            justify-content: space-between;
            height: 50px;
            line-height: 50px;
            padding-left: 100px;
            box-sizing: border-box;
            margin-top: 20px;
            .header-left{
                display: flex;
                 .imgBox{
                    width: 50px;
                    height: 50px;
                    border-radius: 50%;
                    overflow: hidden;
                    background: url('/images/image4.jpg');
                    background-size: cover;
                }
                .tit{
                    color: green;
                    font-weight: 400;
                    font-size: 20px;
                    padding-left: 10px;
                }
                .ms{
                    border-left: 1px solid #ccc;
                    margin-left: 40px;
                    padding-left: 40px;
                    height: 20px;
                    line-height: 20px;
                    margin-top: 15px;
                    font-size: 14px;
                    color: #666;
                }
            }
           
            .toIndex{
                padding-right: 100px;
                color: #333;
                font-size: 14px;
                cursor: pointer;
            }
            .toIndex:hover{
                color: #3b78dd;
                text-decoration: underline;
            }
        }
        .content{
            width: 410px;
            border-radius: 10px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            .center{
               width: 410px;
                .hellow{
                    font-size: 28px;
                    font-weight: 400;
                    color: #333;
                    margin-bottom: 30px;
                }
                .inputBox{
                    width: 420px;
                    margin-bottom: 24px;
                    display:flex;
                    input{
                        width: 380px;
                        height: 46px;
                        outline: none;
                        box-sizing: border-box;
                        border: 1px solid #cbcbcb;
                        border-radius: 3px;
                        padding: 11px 0 10px 16px;
                        font-size: 16px;
                        padding-left: 10px;
                        box-shadow: 1 1 1 1 1 red;
                        box-sizing: border-box;
                    }
                    input:focus{
                        border: 1px solid lawngreen;
                    }
                    span{
                        font-size: 20px;
                        margin-top: 10px;
                        margin-left: 10px;
                        font-weight: bold;
                    }
                    .ture{
                        color: green;
                    }
                    .false{
                        color: red;
                    }
                }
                .check{
                    display: flex;
                    margin-top: 30px;
                    margin-bottom: 0;
                    input{
                        width: 14px;
                    }
                    label{
                        font-size: 14px;
                        color: #adadad;
                        line-height: 42px;
                        margin-left: 10px;
                        a{
                            color: #adadad;
                        }
                        a:hover{
                            text-decoration: underline;
                            color: #333;
                        }
                    }
                }
            }
            .registBtn{
                color: #fff;
                background: #3b78dd;
                font-size: 22px;
                letter-spacing: 2.2px;
                line-height: 48px;
                display: block;
                text-align: center;
                border-radius: 3px;
                width: 100%;
                border: none;
                cursor: pointer;
            }
            .toLogin{
                font-size: 14px;
                width: 100%;
                text-align: center;
                margin-top: 10px;
                span{
                    cursor: pointer;
                    color: red;
                }
                :hover{
                    text-decoration: underline;
                }
            }
        }
    }
</style>